javascript: (function() {
	window.addScriptTag = function(fName, pn) {
		if (!fName) {
			fName = 'log';
		}
		if (!pn) {
			pn = 1;
		}
		var src = 'https://api.bilibili.com/x/v2/reply?callback=' + fName + '&jsonp=jsonp&pn=' + pn + '&type=1&oid=' + window.aid + '&sort=2&_=' + new Date().getTime();
		var script = document.createElement('script');
		script.setAttribute("type", "text/javascript");
		script.setAttribute("async", "false");
		script.src = src;
		document.body.appendChild(script);
	};
	
	window.loadJQ=function(docObj){
		var src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js";
		var script = docObj.createElement('script');
		script.setAttribute("type", "text/javascript");
		script.setAttribute("async", "false");
		script.src = src;
		docObj.head.appendChild(script);
	};
	loadJQ(document);
	
	/*通过bvid获取aid*/
	window.getAid=function(bvid){
		$.ajax({
			url:"https://api.bilibili.com/x/web-interface/view?bvid="+bvid,
			async:false,
			success:function(data){
				window.videoAid=null;
				if(!!data.data){
					data=data.data;
					window.bvid=data.bvid;
					window.videoInfo=data;
					window.videoAid=data.aid;
					window.videoCid=data.cid;
					window.videoPic=data.pic;
					window.videoTitle=data.title;
					window.videoDescr=data.desc;
				}
			}
		});
	};
	
	/*获取data*/
	window.log = function(data) {
		this.data = data;
		console.log(window.data);
		this.allReply = [];
		this.allReply[0] = data.data.replies;
		getPage(data);
	};
	/*获取总页数*/
	window.getPage = function(data) {
		var data2 = data.data;
		this.page = data2.page;
		this.count = page.count;
		this.maxPage = Math.ceil(page.count / page.size);
		this.pageCount = maxPage;
		window.pageConstant=30;
		/*console.log(window.pageCount);*/
		getAllReply();
	};
	/*获取留言*/
	window.getReply = function(data) {
		var data2 = data.data;
		this.allReply.push(data2.replies);
	};
	/*获取全部留言*/
	window.getAllReply = function() {
		/*先快速获取前30页数据*/
		if(pageCount>pageConstant){
			pageCount=pageConstant;
		}
		for (var i = 2; i < pageCount; i++) {
			addScriptTag('getReply', (i));
		}
	};
	/*获取更多留言*/
	window.getMoreReply = function() {
		window.lastPage=pageCount;
		pageCount=pageCount+pageConstant;
		if(pageCount>maxPage){
			pageCount=maxPage;
		}
		for (var i = lastPage; i < pageCount; i++) {
			addScriptTag('getReply', (i));
		}
		if(pageCount<maxPage){
			return true;
		}else{
			return false;
		}
	};
	/*分离出性别*/
	window.parseSex = function(data) {
		return data.member.sex;
	};
	/*性别统计*/
	window.sexCount = function() {
		sexData = [];
		sexData['男'] = 0;
		sexData['女'] = 0;
		sexData['保密'] = 0;
		for (idx1 in allReply) {
			for (idx2 in allReply[idx1]) {
				/*console.info(parseSex(allReply[idx1][idx2]));*/
				sexData[parseSex(allReply[idx1][idx2])]++;
			}
		}
		console.info(sexData);
		return sexData;
	};
	/*分离出用户等级*/
	window.parseLevel = function(data) {
		return data.member.level_info.current_level;
	};
	/*等级统计*/
	window.levelCount = function() {
		leveData = [];
		for (idx1 in allReply) {
			for (idx2 in allReply[idx1]) {
				var level=parseLevel(allReply[idx1][idx2]);
				if(!!leveData[level]){
					leveData[level]++;
				}else{
					leveData[level]=1;
				}
				/*console.info(parseLevel(allReply[idx1][idx2]));*/
			}
		}
		window.leveData=leveData;
		console.info(leveData);
		return leveData;
	};
	
	/*分离出评论时间*/
	window.parseReplyTime = function(data) {
		var nowdate=new Date(data.ctime*1000);
		return nowdate;
	};
	
	/*评论时间统计(年月)*/
	window.replyTimeCountByYearAndMonth = function() {
		replyTimeByYearAndMonthData = [];
		for (idx1 in allReply) {
			for (idx2 in allReply[idx1]) {
				var date=parseReplyTime(allReply[idx1][idx2]);
				var year=date.getYear()+1900;
				var month=date.getMonth()+1;
				var formateDate=year+"年"+month+"月";
				if(!!replyTimeByYearAndMonthData[formateDate]){
					replyTimeByYearAndMonthData[formateDate]++;
				}else{
					replyTimeByYearAndMonthData[formateDate]=1;
				}
				/*console.info(parseReplyTime(allReply[idx1][idx2]));*/
			}
		}
		window.replyTimeByYearAndMonthData=replyTimeByYearAndMonthData;
		console.info(replyTimeByYearAndMonthData);
		return replyTimeByYearAndMonthData;
	};
	
	/*评论时间统计(年月日)*/
	window.replyTimeCountByYearMonthAndDay = function() {
		replyTimeByYearAndMonthData = [];
		for (idx1 in allReply) {
			for (idx2 in allReply[idx1]) {
				var date=parseReplyTime(allReply[idx1][idx2]);
				var year=date.getYear()+1900;
				var month=date.getMonth()+1;
				var day=date.getDate();
				var formateDate=year+"年"+month+"月"+day+"日";
				if(!!replyTimeByYearAndMonthData[formateDate]){
					replyTimeByYearAndMonthData[formateDate]++;
				}else{
					replyTimeByYearAndMonthData[formateDate]=1;
				}
				/*console.info(parseReplyTime(allReply[idx1][idx2]));*/
			}
		}
		window.replyTimeByYearAndMonthData=replyTimeByYearAndMonthData;
		console.info(replyTimeByYearAndMonthData);
		return replyTimeByYearAndMonthData;
	};
	
	/**分离出评论内容和用户信息*/
	window.parseReplyContent = function(data) {
		var msgData={};
		msgData.message=data.content.message;
		msgData.userInfo=data.member;
		msgData.allInfo=data;
		return msgData;
	};
	/*评论关键词检索,content:检索的内容;numbers:匹配的字数;allMatch:是否全词匹配*/
	window.searchReplyContent = function(content,numbers,allMatch,filterVal) {
		contents = [];
		var contentReg=new RegExp("([\\w\\W]*?)"+"(["+content+"]+)"+"([\\w\\W]?)");
		if(!!numbers){
			contentReg=new RegExp("([\\w\\W]*?)"+"(["+content+"]{"+numbers+","+content.length+"})"+"([\\w\\W]?)");
		}
		if(!!allMatch&&allMatch==true){
			contentReg=new RegExp("([\\w\\W]*?)"+"(["+content+"]{"+content.length+"})"+"([\\w\\W]?)");
		}
		for (idx1 in allReply) {
			for (idx2 in allReply[idx1]) {
				var sexData=parseSex(allReply[idx1][idx2]);
				var msgData=parseReplyContent(allReply[idx1][idx2]);
				msgData.page=idx1;
				msgData.row=idx2;
				var message=msgData.message;
				if(!!content){
					if(contentReg.test(message)){
						msgData.message=message.replace(contentReg,"$1<span class='fRed'>$2</span>$3");
						if(!filterVal||filterVal.indexOf(sexData)>-1){
							contents.push(msgData);
						}
						/*console.info(parseReplyContent(allReply[idx1][idx2]));*/
					}
				}else{
					if(!filterVal||filterVal.indexOf(sexData)>-1){
						contents.push(msgData);
					}
				}
			}
		}
		window.contents=contents;
		console.info(contents);
		return contents;
	};
	
	/*过滤粉丝用户信息*/
	window.filterFansReply = function (){
		fansData = [];
		for (idx1 in allReply) {
			for (idx2 in allReply[idx1]) {
				if(!!allReply[idx1][idx2].member.fans_detail){
					var userData=parseReplyContent(allReply[idx1][idx2]);
					userData.page=idx1;
					userData.row=idx2;
					fansData.push(userData);
				}
			}
		}
		window.fansData=fansData;
		console.info(fansData);
		return fansData;
	};
	
	/*初始化*/
	window.init=function(){
		if(!this.allReply){
			addScriptTag();
		}
	};
	init();
	getAid(window.bvid);
	
	/*创建子窗口*/
	window.createSubWin=function(){
		window.subWin=window.open('','子窗口','width=900,height=600,left=450,top=200');
		window.subDoc=subWin.document;
		loadJQ(window.subDoc);
		var htmlContent=`<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>bilibili评论统计分析工具</title>
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
		<style>
			body {
				margin: 0px;
				padding: 0px;
			}

			.topContent {
				position: fixed;
				height: 50px;
				width: 100%;
				background-color: #FFFFFF;
				z-index: 12;
				margin: 0;
				padding: 0;
				text-align: center;
				box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08);
			}

			.menuContent {
				position: fixed;
				padding: 0;
				margin: 0;
				left: 0;
				top: 0;
				bottom: 0;
				right: 0;
				background-color: #23ade5;
				color: white;
				width: 130px;
				box-shadow: 1px 1px 5px #888888;
				z-index: 11;
			}

			.menuContent>div:first-child {
				margin-top: 50px;
				text-align: center;
			}

			.menuContent div {
				/* margin-top: 10px; */
				text-align: center;
				vertical-align: middle;
				float: left;
				width: 115px;
			}

			.menu {
				border: #FFFFFF solid 1px;
				margin-top: 15px;
				padding-right: 2px;
				margin-left: 5px;
				box-shadow: 1px 1px 5px #888888;
			}

			.menu:hover {
				background-color: rgb(35, 220, 220);
				cursor: pointer;
			}

			.dataContent,.indexContent {
				--ml:130px;
				margin-left: var(--ml);
				padding-top: 60px;
				padding-left: 0;
				padding-right: 0;
				--mw:800px;
				min-width: calc(var((--mw)-(--ml)));
				min-height: 270px;
				z-index: 10;
				/*background-color: #F5F5DC;*/
			}
			
			.indexContent{
				text-align: center;
			}
			.indexContent div{
				text-align: left;
				width: 70%;
				display: inline-block;
				font-size: 20px;
			}
			#checkVersionH {
			    font-size: 32px;
			}
			
			.dataContent{
				display: none;
			}

			.icons {
				background-image: url("https://static.hdslb.com/images/base/icons.png");
				background-repeat: no-repeat;
				background-position: 0px 0px;
				width: 50px;
				height: 50px;
				float: left;
				--bgx: -135px;
				--bgy: -75px;
			}

			.icon1 {
				background-position: var(--bgx) calc(var(--bgy)*1.1);
			}

			.icon2 {
				background-position: var(--bgx) calc(var(--bgy)*1.9);
			}
			
			.replyDiv {
				background-color: white;
				width: 638px;
			}
			
			.userImg img {
				height: 48px;
				width: 48px;
				vertical-align: middle;
				border-radius: 50%;
				padding: 0px 5px;
			}
			
			.userName {
				display: inline;
				vertical-align: middle;
				margin-left: 5px;
			}
			
			.levelImg {
				background-image: url(https://static.hdslb.com/phoenix/dist/images/icons-comment.png);
				display: inline-block;
				width: 19px;
				height: 9px;
				vertical-align: middle;
				margin: 0 8px;
				--levelImgX:-23px;
				--levelImgBaseY:-92px;
				--unit:-64px;
				--levelImgY: calc(0% + var(--levelImgBaseY) + calc(var(--unit) * var(--times)));
				background-position: var(--levelImgX) var(--levelImgY);
			}
			.levelImg1 {
				--times:0;
			}
			.levelImg2 {
				--times:1;
			}
			.levelImg3 {
				--times:2;
			}
			.levelImg4 {
				--times:3;
			}
			.levelImg5 {
				--times:4;
			}
			.levelImg6 {
				--times:5;
			}
			.levelImg7 {
				--times:6;
			}
			.levelImg8 {
				--times:7;
			}
			.replyContent{
				margin-left: 58px;
				border-bottom: 1px solid #e5e9ef;
				padding-bottom: 5px;
			}
			.replyContentDiv{
				text-align: center;
				display: none;
			}
			#replyContentList{
				text-align: left;
				margin-left: 85px;
			}
			
			.searchDiv{
				width: 638px;
				position: fixed;
				text-align: left;
				margin-left: 85px;
				padding: 0px;
				margin-top: -10px;
				background-color: white;
			}
			.searchInput{
				width: 90%;
				overflow: hidden;
				height: 34px;
				background: #F4F4F4;
				border: 1px solid #E7E7E7;
				box-shadow: none;
				color: #999;
				font-size: 14px;
				line-height: 34px;
				vertical-align: middle;
			}
			.searchInput:hover{
				background-color: rgba(240, 240, 240, 1);
			}
			.searchButton{
				height: 34px;
				width: 50px;
				text-align: center;
				vertical-align: middle;
				display: inline-block;
				margin: auto 0;
				padding-top: 10px;
				background-color: #c5cbcc;
				color: white;
			}
			.searchButton:hover {
			    background-color: #979a9a;
				cursor: pointer;
			}
			span.fRed {
			    color: red;
			}
			.fansSign{
				border: 1px solid #2EBDA7;
				color: #2EBDA7;
				border-radius: 3px;
				vertical-align: middle;
			}
			
			.bili_logo{
				float: left;
				color: white;
				font-size: 32px;
				color: #00a1d6;
				vertical-align: middle;
				margin: 5px;
			}
			.bili_logo div{
				margin: 5px;
				display: inline;
			}
			
			.note{
				color: red;
			}
			
			.textMid{
				vertical-align: middle;
			}
			
			#bvidInput{
				border: #00a1d6;
				border-style: solid;
				width: 250px;
				height: 22px;
			}
			#errMsg{
				color: red;
			}
			#otherVideoInfo{
				font-size: small;
				border: #00a1d6;
				border-style: solid;
				padding-left: 8px;
			}
			table{
				table-layout: fixed;
				width: 100%;
				text-align: center;
			}
			td{
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				vertical-align: top;
			}
			#otherVideoPic{
				height: 68px;
			}
			#otherVideoDescr{
				height: 68px;
				overflow-x: hidden;
				font-family: Microsoft YaHei;
			}
			
			.button{
				display: inline-block;
				font-size: small;
				border: #d4d3d3;
				border-style: outset;
				background-color: #ffffff;
				padding: 4px;
			}
			.button:active{
				background-color: #c4c4c4;
			}
			.ml15{
				margin-left: 15px;
			}
			.hidden{
				display: none;
			}
			.vt{
				vertical-align: top;
			}
			
			#loading{
				border: #00a1d6;
				border-style: solid;
				text-align: center;
			}
			
			#getMoreData span{
				display: block;
				margin: auto 0;
				font-size: 14px;
				padding-top: 2px;
			}
			
			#per{
				margin: 2px;
				height: 20px;
				font-size: 18px;
				background-color: white;
				width: 5%;
				text-align: right;
				color: #068e06;
				font-weight: 900;
				font-family: "agency fb";
				padding-right: 12px;
				transition: all 1s cubic-bezier(1,1,1,1);
				background-size: 50px 25px;
				background-image: 
				linear-gradient(
					60deg
					,transparent 15px,#4DAFE1 15px,#4DAFE1 25px,transparent 25px
					,transparent 35px,#4DAFE1 35px,#4DAFE1 45px,transparent 45px
				);
				animation: myloading 30s infinite cubic-bezier(1, 1, 1, 1);
			}
			
			@keyframes myloading{
				from{background-position-x: 0px;}
				to{background-position-x: 125rem;}
			}

			#searchFilter{
				text-align: right;
				margin-top: 5px;
			}

			#searchFilter input{
				vertical-align: top;
				height: 15px;
				width: 15px;
				margin-right: 10px;
			}
			
		</style>
	</head>
	<body>
		<div class="topContent">
			<i class="bilifont bili-Navbar_logo bili_logo">
				<div>
					评论统计分析工具
				</div>
			</i>
		</div>
		<div class="menuContent">
			<div>
				<div class="menu">
					<div onclick="showIndex()">首页</div>
				</div>
			</div>
			<div>
				<div class="menu">
					<div onclick="sexCount()">用户性别统计</div>
				</div>
			</div>
			<div>
				<div class="menu">
					<div onclick="replyTimeCount()">评论时间段统计</div>
				</div>
			</div>
			<div>
				<div class="menu">
					<div onclick="levelCount()">用户等级统计</div>
				</div>
			</div>
			<div>
				<div class="menu">
					<div onclick="searchReplys()">关键字搜索</div>
				</div>
			</div>
			<div>
				<div class="menu">
					<div onclick="fansReplys()">牌粉留言信息</div>
				</div>
			</div>
			<div>
				<div class="menu">
					<div onclick="videoPic()">视频卷轴图</div>
				</div>
			</div>
		</div>
		<div class="indexContent" id="indexContent">
			<h2 id="checkVersionH">插件更新检测...</h2>
			<h2 id="getMoreData">
				<span>准备获取评论数据</span>
				<div id="loading">
					<dir id="per"></dir>
				</div>
			</h2>
			<h2 id="bvidTitle">
				<div>
					<span class="textMid">当前统计视频:</span>
					<input id="bvidInput" class="ml15" type="text" placeholder="输入视频的BV号"/>
					<span class="button ml15" onclick="changeVideo()">切换统计视频</span>
					<div id="errMsg"></div>
					<table id="otherVideoInfo">
						<tr>
							<td>
								<p>
									<span>标题：</span><span id="otherVideoTitle"></span>
								</p>
								<img id="otherVideoPic" class="hidden" alt="无法获取缩略图"/>
							</td>
							<td>
								<p>
									<span class="vt">描述：</span>
								</p>
								<textarea id="otherVideoDescr" readonly="readonly"></textarea>
							</td>
						</tr>
					</table>
				</div>
			</h2>
		<div><span class="note">注意事项:</span><br>请勿短时间内在多个视频中使用该插件,否则可能会被B站官方暂时封锁IP,导致10分钟内无法查看视频评论,同时也无法使用该插件(目前该插件每次抓取30页的评论)</div>
		<div><br><br><a href="#" onclick="window.open('https://space.bilibili.com/14618291')">作者B站主页</a></div>
		</div>
		<div class="dataContent" id="dataContent">

		</div>

		<div class="dataContent replyContentDiv" id="replyContent">
			<dir class="searchDiv">
				<input class="searchInput" id="searchInput" onkeydown="keySearch()" />
				<div class="searchButton" onclick="showReplysContent()">
					<span>搜索</span>
				</div>
				<div id="searchFilter">
					<span>男性：</span><input type="checkbox" value="男"/>
					<span>女性：</span><input type="checkbox" value="女"/>
					<span>保密：</span><input type="checkbox" value="保密"/>
				</div>
			</dir>
			<div class="dataContent" id="replyContentList">

			</div>
		</div>

		<script>
			var opener = window.opener;
			var toolVersion = '版本号###version20210813141015###';
			var newVersion = '';
			var timeOut = 5;

			function ready() {
				showIndex();
				if(!!opener){
					if(!!opener.bvid){
						$("#bvidInput").val(opener.bvid);
					}
					showVideoInfo();
				}
				$("#getMoreData span").text("准备获取评论数据");
				$("#per").text("");
				$("#per").css("animation-play-state","running");
				updateTimeOut();
			}

			function showIndex() {
				console.log("showIndex");
				$("#indexContent").css("display", "block");
				$("#replyContent").css("display", "none");
				$("#dataContent").css("display", "none");
				/* setTimeout("checkVersion()",3*1000); */
			}

			function checkVersion() {
				console.log("checkVersion");
				if (!!newVersion && toolVersion != newVersion) {
					/*alert("有新版本!");*/
					$("#checkVersionH").html("有新版本,请下载最新版本插件!<a href='javascript:download()'>下载页面</a>");
				} else {
					$("#checkVersionH").text("该插件已经是最新版本");
				}
			}

			function download(){
				open("https://gitee.com/x616717724/bilibiliReplyTool");
			}

			function updateTimeOut() {
				if (0 < timeOut && timeOut <= 5) {
					timeOut--;
					/*$("#getMoreData").text(timeOut + "s后抓取更多评论数据");*/
					console.log(timeOut + "s后抓取更多评论数据");
					setTimeout("updateTimeOut()", 1 * 1000);
				} else {
					timeOut = 5;
					$("#getMoreData span").text("正在获取评论数据");
					console.log("正在获取评论数据");
					if(!!opener.lastPage&&!!opener.maxPage){
						var per=opener.lastPage/opener.maxPage;
						if(per>=1){
							per=1;
							$("#per").css("width","auto");
						}else{
							$("#per").css("width",(per*100)+"%");
						}
						$("#per").text(Math.ceil(per*100)+"%");
						$("#per").css("animation-play-state","running");
					}
					setTimeout("getMoreReply();", 1 * 1000);
				}
			}

			function getMoreReply() {
				if (opener.getMoreReply()) {
					setTimeout("updateTimeOut();", 1 * 1000);
				} else {
					$("#getMoreData span").text("已获取所有评论数据");
					console.log("已获取所有评论数据");
					$("#per").css("width","auto");
					$("#per").text(100+"%");
					$("#per").css("animation-play-state","paused");
				}
			}

			function sexCount() {
				if (!!opener) {
					setSexEcharts();
				}
			}

			function levelCount() {
				if (!!opener) {
					setLevelEcharts();
				}
			}

			function replyTimeCount() {
				if (!!opener) {
					setReplyTimeByYearAndMonthEcharts();
				}
			}

			function searchReplys() {
				if (!!opener) {
					$("#dataContent").css("display", "none");
					$("#indexContent").css("display", "none");
					$(".searchDiv").css("display", "block");
					$("#replyContent").css("display", "block");
					$("#replyContentList").css("display", "block");
				}
			}

			function fansReplys() {
				if (!!opener) {
					$("#dataContent").css("display", "none");
					$("#indexContent").css("display", "none");
					$(".searchDiv").css("display", "none");
					$("#replyContent").css("display", "block");
					$("#replyContentList").css("display", "block");
					showFansReplys();
				}
			}
			
			function changeVideo(){
				if (!!opener) {
					/*更新aid*/
					opener.getAid($("#bvidInput").val());
					if(!opener.videoAid){
						$("#errMsg").text("无法通过该BV号查找到视频");
					}else{
						$("#errMsg").text("");
						showVideoInfo();
						reload();
					}
				}
			}
			
			function showVideoInfo(){
				$("#otherVideoInfo").show();
				$("#otherVideoTitle").text(opener.videoTitle);
				$("#otherVideoPic").show();
				$("#otherVideoPic").attr("src",opener.videoPic);
				$("#otherVideoDescr").val(opener.videoDescr);
			}
			
			function videoPic(){
				if(!!opener){
					opener.open("https://i0.hdslb.com/bfs/videoshot/"+opener.videoCid+".jpg");
				}
			}
			
			function reload(){
				/*切换aid*/
				opener.aid=opener.videoAid;
				/*清除历史数据*/
				opener.allReply=null;
				/*重新初始化脚本*/
				opener.init();
				/*重新初始化页面*/
				ready();
			}
		</script>

		<script>
			function setSexEcharts() {
				var sexData = opener.sexCount();
				var sexDataKeys = Object.keys(sexData);
				var legendData = [];
				var seriesData = [];
				for (var i = 0; i < sexDataKeys.length; i++) {
					var dataValue = sexData[sexDataKeys[i]];
					var dataName = sexDataKeys[i];
					if (!!dataValue) {
						legendData.push(dataName);
						seriesData.push({
							value: dataValue,
							name: dataName
						});
					}
				}
				setPieChart('评论用户性别统计', legendData, seriesData);
			}

			function setLevelEcharts() {
				var levelData = opener.levelCount();
				var levelDataKeys = Object.keys(levelData);
				var seriesDataName = [];
				var seriesDataValue = [];
				for (var i = 0; i < levelDataKeys.length; i++) {
					var dataValue = levelData[levelDataKeys[i]];
					var dataName = levelDataKeys[i];
					if (!!dataValue) {
						seriesDataName.push(dataName);
						seriesDataValue.push(dataValue);
					}
				}
				setHistogramChart('评论用户等级统计', seriesDataName, seriesDataValue);
			}

			function setReplyTimeByYearAndMonthEcharts() {
				var replyTimeData = opener.replyTimeCountByYearMonthAndDay();
				var replyTimeDataKeys = Object.keys(replyTimeData);
				var seriesData = [
					['0', 0]
				];
				if (1 < replyTimeDataKeys.length) {
					seriesData = [];
				}
				/*时间排序*/
				for (var i = 0; i < replyTimeDataKeys.length - 1; i++) {
					for (var j = 0; j < replyTimeDataKeys.length - 1 - i; j++) {
						if (parseDateToCompare(replyTimeDataKeys[j], replyTimeDataKeys[j + 1]) > 0) {
							var temp = replyTimeDataKeys[j];
							replyTimeDataKeys[j] = replyTimeDataKeys[j + 1];
							replyTimeDataKeys[j + 1] = temp;
						}
					}
				}
				for (var i = 0; i < replyTimeDataKeys.length; i++) {
					var dataValue = replyTimeData[replyTimeDataKeys[i]];
					var dataName = replyTimeDataKeys[i];
					if (!!dataValue) {
						seriesData.push([dataName, dataValue]);
					}
				}
				setLineChart('评论用户时间段统计', seriesData);
			}

			function parseStrDate(date) {
				return new Date(date.replace(/[年月日]/g, '/'));
			}

			function parseDateToCompare(date1, date2) {
				date1 = parseStrDate(date1);
				date2 = parseStrDate(date2);
				return date1.getTime() - date2.getTime();
			}

			/*设置饼状图*/
			function setPieChart(title, legendData, seriesData) {
				option = {
					title: {
						text: title,
						subtext: '',
						left: 'center'
					},
					tooltip: {
						trigger: 'item',
						formatter: '{a} <br/>{b} : {c} ({d}%)'
					},
					legend: {
						orient: 'vertical',
						left: 'left',
						data: legendData
					},
					series: [{
						name: '',
						type: 'pie',
						radius: '70%',
						center: ['50%', '60%'],
						data: seriesData
					}]
				};
				setEcharts(option);
			}

			/*设置线状图*/
			function setLineChart(title, seriesData) {
				option = {
					title: {
						text: title,
					},
					tooltip: {
						trigger: 'axis'
					},
					toolbox: {
						show: true,
						feature: {
							magicType: {type: ['line', 'bar']},
						}
					},
					xAxis: {
						type: 'category',
						boundaryGap: false,
					},
					yAxis: {
						type: 'value',
					},
					series: [
						{
							name: '评论数',
							type: 'line',
							data: seriesData,
							markLine: {
								data: [
									{type: 'average', name: '平均值'}
								]
							}
						}
					]
				};
				setEcharts(option);
			}

			function setHistogramChart(title, seriesDataName, seriesDataValue) {
				option = {
					color: ['#3398DB'],
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'shadow'
						}
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					xAxis: [{
						type: 'category',
						data: seriesDataName,
						axisTick: {
							alignWithLabel: true
						}
					}],
					yAxis: [{
						type: 'value'
					}],
					series: [{
						name: title,
						type: 'bar',
						barWidth: '60%',
						data: seriesDataValue
					}]
				};
				setEcharts(option);
			}

			/*设置Echarts*/
			var myChart;

			function setEcharts(option) {
				$("#indexContent").css("display", "none");
				$("#replyContent").css("display", "none");
				$("#dataContent").css("display", "block");
				if (!myChart) {
					var myChart = echarts.init(document.getElementById('dataContent'));
				}
				myChart.clear();
				myChart.setOption(option);
			}
		</script>

		<script>
			var replyDivTemplate = '';
			var replyDivTemplate =
				'<div class="replyDiv"><div class="userImg"><img src="@uImg@"/><span class="fansSign">@uFansTitle@<span class="fansSignLevel">@uFansLevel@</span></span><div class="userName">@uName@</div><dir class="levelImg levelImg@uLevel@"></dir></div><div class="replyContent">@uContent@</div></div>';

			function showReplysContent() {
				var contents;
				var checkboxs=$("#searchFilter input:checkbox");
				var filterVal='';
				for(var i=0;i<checkboxs.length;i++){
					if($(checkboxs[i]).prop("checked")){
						filterVal+=$(checkboxs[i]).val();
					}
				}
				if($("#searchInput").val().length>1){
					contents = opener.searchReplyContent($("#searchInput").val(),2,false,filterVal);
				}else{
					contents = opener.searchReplyContent($("#searchInput").val(),0,false,filterVal);
				}
				var replyDivHtml = '';
				if (!!contents) {
					for (var i = 0; i < contents.length; i++) {
						replyDivHtml += parseReplyContent(contents[i]);
					}
				}
				$("#replyContentList").html(replyDivHtml);
			}

			function keySearch() {
				if (window.event.key == 'Enter') {
					showReplysContent();
				}
			}

			function parseReplyContent(content) {
				var uImg = content.userInfo.avatar;
				var uName = content.userInfo.uname;
				var uLevel = content.userInfo.level_info.current_level;
				var uContent = content.message;
				/*返回HTML结果*/
				var replyDiv = replyDivTemplate.replace('@uImg@', uImg).replace('@uName@', uName).replace('@uLevel@', uLevel).replace(
					'@uContent@', uContent);
				var allInfo = content.allInfo;
				var fans_detail = allInfo.member.fans_detail;
				if (!!fans_detail) {
					var uFansTitle = fans_detail.medal_name;
					var uFansLevel = fans_detail.level;
					replyDiv = replyDiv.replace('@uFansLevel@', uFansLevel);
					replyDiv = replyDiv.replace('@uFansTitle@', uFansTitle);
				} else {
					replyDiv = replyDiv.replace('@uFansLevel@', '');
					replyDiv = replyDiv.replace('@uFansTitle@', '');
				}
				return replyDiv;
			}

			function showFansReplys() {
				var contents = opener.filterFansReply();
				var replyDivHtml = '';
				if (!!contents) {
					for (var i = 0; i < contents.length; i++) {
						replyDivHtml += parseReplyContent(contents[i]);
					}
					if (contents.length == 0) {
						replyDivHtml = '该UP暂时未拥有牌粉';
					}
				} else {
					replyDivHtml = '该UP暂时未拥有牌粉';
				}
				$("#replyContentList").html(replyDivHtml);
			}
		</script>
	</body>
</html>
`;
		subDoc.write(htmlContent);
		subWin.data=window.data;
		setTimeout("subWin.ready();",1*1000);
	};
	createSubWin();
	/*复制b站CSS*/
	$(document).find("style").each(function (i,o){
		$(o).clone().appendTo(subDoc.head);
	});
	
	/*检测版本页面*/
	window.createVersionFrame=function(){
		$.ajax({
			url:'https://www.bilibili.com/read/cv7275487',
			success:function (data){
				/*console.log(data);*/
				versionReg=/<blockquote>.*?版本号###.*?###.*?<\/blockquote>/;
				versionElem=versionReg.exec(data);
				console.log(versionElem);
				if(!!versionElem){
					newVersion=versionElem[0].replace(/<blockquote>.*?(版本号###.*?###).*?<\/blockquote>/,"$1");
				}
				subWin.newVersion=window.newVersion;
				subWin.checkVersion();
			}
		});
	};
	setTimeout("createVersionFrame()",2*1000);

})();
